import { Entity, PrimaryGeneratedColumn, Column,Index, Timestamp, OneToOne, JoinColumn } from 'typeorm';
import { LoginType } from '../consts/login_type';
import { Player } from './player.entity';

@Entity("user")
export class User {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  nickName: string;

  @Column()
  avatarUrl: string;

  @Column()
  country: string;

  @Column()
  @Index({ unique: true })
  uniqueKey:string;

  @Column()
  man: boolean;

  @Column("enum", {enum: LoginType})
  loginType:LoginType;

  @Column()
  score:number=0;

  @Column()
  lastLoginTime:Date=new Date();

  @OneToOne(type => Player, player => player.user, {
    cascade: ["insert"],
    eager:true
})
  @JoinColumn()
  player: Player;


}